/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistencia;

import bean.Empresa;
import bean.Vaga;
import interfaces.VagaInterface;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author VENANCIO
 */
public class VagaDao implements VagaInterface{

    private Connection con;
    private String sql;
    private Vaga candidato;
    private List<Vaga> listaVaga;
    
    public VagaDao(){
        
    }
    
    @Override
    public void inserir(Vaga vaga) {
        sql="INSERT INTO VAGA(VAGA_EMPRESA, VAGA_PERIODO, VAGA_CARGA_HORARIA, VAGA_BOLSA, VAGA_BENEFICIOS,"
                + " VAGA_TITULO, VAGA_QUANTIDADE, VAGA_REQUISITOS, VAGA_LOCAL, VAGA_DESCRICAO)"
                + " VALUES(?,?,?,?,?,?,?,?,?,?)";
        try {
            con = new Conexao().getConexao();
            PreparedStatement stmt = con.prepareStatement(sql);
            int count=1;
            stmt.setString(count++, vaga.getEmpresa());
            stmt.setObject(count++, vaga.getPeriodo());
            stmt.setString(count++, vaga.getCaragaHoraria());
            stmt.setDouble(count++, vaga.getBolsa());
            stmt.setString(count++, vaga.getBeneficio());
            stmt.setString(count++, vaga.getTitulo());
            stmt.setInt(count++, vaga.getQuantidade());
            stmt.setString(count++, vaga.getRequisitos());
            stmt.setString(count++, vaga.getLocal());
            stmt.setString(count++, vaga.getDescricao());
            stmt.executeUpdate();
            stmt.close();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(VagaDao.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(VagaDao.class.getName()).log(Level.SEVERE, null, ex);
        }finally{
            try {
                con.close();
            } catch (SQLException ex) {
                Logger.getLogger(VagaDao.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    @Override
    public List<Vaga> consulta(Vaga vaga) {
        List<Vaga> listaVaga = new ArrayList<Vaga>();
        
        sql = "SELECT * FROM VAGA WHERE 1=1 ";
        if(vaga.getCodVaga()!=0){
            sql = sql + " VAGA_COD = " + vaga.getCodVaga();
        }
        if(vaga.getEmpresa().length()!=0){
            sql = sql + " VAGA_EMPRESA = " + vaga.getEmpresa();
        }
        if(vaga.getTitulo().length()!=0){
            sql = sql + " VAGA_TITULO LIKE '";
        }
        
        
        return listaVaga;
    }

    @Override
    public List<Vaga> consulta() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<Vaga> consultaEmpresaVaga(Empresa empresa) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void alterar(Vaga vaga) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void excluir(Vaga vaga) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    
    
}
